home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZFile.h -- a generic file object
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- *
- *
- *
- *
- *************************************************************************************************/
-
-
-
- #pragma once
-
- #ifndef __ZFILE__
- #define __ZFILE__
-
- #ifndef __ZCOMRADE__
- #include "ZComrade.h"
- #endif
-
- #include <Files.h>
-
-
-
- class ZFile : public ZComrade
- {
- protected:
-
- short refNum; // data fork ref num when open
- short resRefNum; // resource fork ref num when open
- Boolean isSafeSave; // TRUE if this was a safe-save Write
- OSType itsType; // file type
- FSSpec itsSpec; // file spec (name and location)
- FSSpec ssFSpec; // temp file spec for safe-save
-
- public:
-
- ZFile( const FSSpec& aSpec );
- ZFile( Str255 fName );
- ~ZFile();
-
- // file opening and closing
- virtual void Open();
- virtual void Close();
- virtual void OpenSafe();
-
- // creating/destroying a new file on disk
- virtual void Create();
- virtual void Discard();
-
- // accessing the resource fork
- virtual void OpenResFork();
- virtual void CloseResFork();
- virtual void CreateResFork();
- virtual void SetResFork( short* curRes );
-
- // reading and writing file data
- virtual void Read( Ptr inBuffer, long* howMuch );
- virtual void Write( Ptr outBuffer, long* howMuch );
- virtual void Read( Handle aHandle );
- virtual void Write( Handle aHandle );
-
- // file positioning and info
- virtual long GetMark();
- virtual void SetMark( const long aMark );
-
- virtual OSType GetType();
- virtual void SetType( const OSType aType );
-
- virtual long GetLength();
- virtual void SetLength( const long aLength );
-
- virtual void GetFSSpec( FSSpec* aSpec );
-
- // fork info
- virtual Boolean HasResFork();
- virtual Boolean HasDataFork();
-
- // disk file info
- virtual Boolean IsReal();
- virtual Boolean IsLocked();
- virtual Boolean IsOpen();
-
- protected:
-
- virtual void InitFile();
- };
-
-
- #define _NOT_OPEN -1
- #define kUnknownType '????'
-
- #endif